package com.bharatonjava.hospital.web.validators;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.bharatonjava.hospital.web.formbean.PatientFormBean;

public class PatientFormBeanValidator implements Validator {

	@Override
	public boolean supports(Class<?> aClass) {
		return PatientFormBean.class.equals(aClass);
	}

	@Override
	public void validate(Object obj, Errors errors) {
		try{
		System.out.println("**********************");
		PatientFormBean formBean = (PatientFormBean) obj;
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "patient.firstName", "First Name is Required");
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
